<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="../templates/util.js"></script>
</head>
<body>
    <div id="app">
            姓名：<input type="text" v-model="pojo.name"/><br/>
            年龄：<input type="text" v-model="pojo.age"/><br/>
            性别：<input type="radio" value="男" v-model="pojo.sex"/>男
                  <input type="radio" value="女" v-model="pojo.sex"/>女<br/> 
            <button type="button" @click="update()">修改</button>
    </div>
    <script>
        new Vue({
            el: "#app",
            data: {
                pojo: {}
            },
            created() {
                this.findById();
            },
            methods: {
                findById() {
                    axios.post("http://localhost:8080/user/findByid?id="+getQueryString("id")).then(res => {
                        this.pojo = res.data;
                    })
                },
                update() {
                    axios.post("http://localhost:8080/user/update",this.pojo).then(res => {
                        location.href = "show.html";
                    })
                }
            }
        })
    </script>
</body>
</html>